<?php

class LetterStationDao {
	public $table  = 'letter_station';
	
	public function add($data){
		ClassManager::getSql()->insert($this->table, $data);
	}
	public function count($where){
		$where = $this->searchWhere($where);
		$count = ClassManager::getSql()->onedata1($this->table,"count(*)  ",$where);
		return  $count[0];
	}
	public function getList($where=array(),$order='',$limit=0){
		$where = $this->searchWhere($where);

		return  ClassManager::getSql()->dataList1($this->table,'*',$where,$order,$limit);
	}
	public function searchWhere ($where){
		$where1 = array();
		foreach ($where as  $k=>$v){
			if (!($v==='')){
				$where1[$k] = $v;
			}
		}
		return $where1;
	}
	public function addArray($data){
		ClassManager::getSql()->insertArray($this->table, array('sender','user_id','title','content','time'), $data);
	}
	public function get($id){
		return ClassManager::getSql()->oneDataCache($this->table, 'id', intval($id));
	}
	public function update($data,$id){
		ClassManager::getSql()->update($this->table, $data,"where id=".intval($id));
	}
}
?>